#include <iostream>
#include "piece.h"

using namespace std;

ostream& operator<<(ostream& output, const Piece& myPiece)
{
	// outputs the rank to a stream
	output << myPiece.getRank();
}

Piece::Piece(void)
: rank(-1), descr("blank"), shortDescr(' '), owner(-1), known(false)
{
	// initializes the variables
}

Piece::Piece(int initRank, int initOwner, bool isKnown)
: rank(initRank), owner(initOwner), known(isKnown)
{
	// initializes the piece with the given rank and owner
	string descrArray[14] = {"Water","Blank","Spy","Marshal","General",
	                        "Colonel","Major","Captain","Lieutenant",
	                        "Sergeant","Miner","Scout","Bomb","Flag"};
	char shortArray[14] = {'~',' ','S','1','2','3','4','5','6','7','8','9','B','F'};

	descr = descrArray[initRank + 2];
	shortDescr = shortArray[initRank + 2];
}

void Piece::setRank(int newRank)
{
	// set the rank
	rank = newRank;
	return;
}

void Piece::setOwner(int newOwner)
{
	// set the owner
	owner = newOwner;
	return;
}

void Piece::setKnown(bool k)
{
	// set the known flag
	known = k;
}

int Piece::getRank(void) const
{
	// return the rank
	return rank;
}

bool Piece::getKnown()
{
	return known;
}

string Piece::getDescr(void) const
{
	// return the description
	return descr;
}

char Piece::getShortDescr(void) const
{
	// return the single character description
	return shortDescr;
}

int Piece::getOwner(void) const
{
	// return the owner
	return owner;
}

